package csdn;

import java.util.*;

/**
 * 项目名称：wangxu
 * 类 名 称：找字符
 * 描 述：https://dream.blog.csdn.net/article/details/129488191
 * 创建时间：2023/4/13 07:25 下午
 * 创 建 人：wang-xu
 */
public class RealTopic10 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        try {
            String str1 = in.nextLine();
            String str2 = in.nextLine();
            if (str1.length() < 1 || str2.length() >1024){
                System.out.println("input error");
            }
            if (str2.length() < 1 || str2.length() >100){
                System.out.println("input error");
            }

            char[] str1Chars = str1.toCharArray();
            Set<Character> set = new TreeSet<>();
            for (char c:str1Chars) {
                if (str2.contains(String.valueOf(c))){
                    set.add(c);
                }
            }
            StringBuilder sb = new StringBuilder();
            for (char c:set) {
                sb.append(c);
            }
            System.out.println(sb);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
